package triprecorder;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;


public class TripRecorder 
{
	private final static String filename = "TripRecords.dat";
	private ArrayList<Trip> rideList = new ArrayList<Trip>();
	
	
	public TripRecorder(){
		
	}
	
	synchronized public void touchIn(Trip trip){
		rideList.add(trip);
	}

	synchronized public void touchOut(Trip trip) throws IOException{
		ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename));
		rideList.remove(trip);			
		out.writeObject(trip);
		out.close();
	}

}